package com.hubu.parking.controller;

import cn.hutool.json.JSONObject;
import com.hubu.parking.common.BaseResponse;
import com.hubu.parking.common.ResultUtils;
import com.hubu.parking.model.dto.park.CancelReserveDto;
import com.hubu.parking.model.dto.park.GetCurrentMessageDto;
import com.hubu.parking.service.ParkingReservationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 预约接口
 */
@RestController
@RequestMapping("/reservation")
@Slf4j
public class ReservationController {

    @Resource
    private ParkingReservationService reservationService;

    /**
     * 查询
     *
     * @return
     */
    @PostMapping("/getCurrentMessage")
    public BaseResponse<JSONObject> listSpot(@RequestBody GetCurrentMessageDto dto) {
        return ResultUtils.success(reservationService.getCurrentMessage(dto));
    }

    /**
     * 取消预约
     *
     * @return
     */
    @PostMapping("/cancelReserve")
    public BaseResponse<Integer> cancelReserve(@RequestBody CancelReserveDto dto) {
        return ResultUtils.success(reservationService.cancelReserve(dto));
    }
}
